#include <bits/stdc++.h>
#define fi first
#define se second
using ll = long long;
using namespace std;
const int N = 3e5 + 10;
const int M = 1e9 + 7;
int a[N], w[N], s[N];
ll f(int l, int r)
{
    return (s[r] - s[l - 1]) * w[r - l + 1];
}
void solve()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        s[i] = s[i - 1] + a[i];
    }
    for (int i = 1; i <= n; i++)
    {
        cin >> w[i];
    }
    int ans = 0;
    for (int l = 1; l <= n; l++)
    {
        for (int r = l; r <= n; r++)
        {
            ans += f(l, r);
        }
    }
    cout << ans % M;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios::sync_with_stdio(false);
    int T = 1;
    // cin>>T;
    while (T--)
    {
        solve();
    }
    return 0;
}